#!/usr/bin/env python
# encoding: utf-8


"""
@file: guodian.py
@time: 2017/1/6 下午4:57
"""
from mathsolver.functions.base import *
from sympy import tan
from mathsolver.functions.sanjiao import sanjiao_utils as su
from mathsolver.functions.sanjiao.geizhiqiuzhi import QiuZhi
from mathsolver.functions.sanjiao.sanjiao_constants import QUADRANT_SEARCH_SUFFIX


# 若角α的终边经过点P(3,2)
class JiaoZhongBianGuoDian(BaseFunction):
    def solver(self, *args):
        self.label.add('任意角的三角函数定义')
        varable = args[0].sympify()
        arg0 = args[1]
        x_value, y_value = arg0.sympify()
        var_quad = su.get_quadrant_with_x_y(x_value, y_value)
        r_eq = BaseEq([tan(varable), y_value / x_value])
        arg1 = args[2]
        target_f = arg1.sympify()
        self.steps.append(['由题意可知', 'x =%s, y=%s' % (new_latex(x_value), new_latex(y_value))])
        poly_solve = QiuZhi(verbose=True)
        poly_solve.known[sympify(str(varable) + QUADRANT_SEARCH_SUFFIX)] = var_quad
        poly_solve = poly_solve.solver(r_eq, BasePoly(target_f))
        self.steps.extend(poly_solve.steps)
        self.output.extend(poly_solve.output)
        return self
